package util.base.impl;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;
import java.util.Properties;

import util.base.ConfigBase;

public class ConfigBaseImpl implements ConfigBase {
	private Properties pro = new Properties();
	@Override
	public String getConfig(String name,String path) {
		String value=null;
		InputStream in=null;
		String rootPath=System.getProperty("user.dir");
		path=rootPath+path;
		try {
			 in= new BufferedInputStream (new FileInputStream(path));
			 pro.load(in);
			 Iterator<String> it=pro.stringPropertyNames().iterator();
			 while(it.hasNext()){
			     if(it.next().equals(name)){
			    	 value=pro.getProperty(name);
			     }
			  }
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			try {
				in.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return value;
	}
}
